Troubleshooting USB dongle

Currently the USB dongle is support under Linux and Flatpak for the platforms listed:

When using the oeSENC module, after installing and enabling the plugin you should see under the Charts menu a Section oeSENC Charts.

After pressing “Refresh Chart list” you should see a “System Name: sglXXXXXXXX (USB Key Dongle)”.

If this does not show you can test the binary backend with:

 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -a
oeserverd Version 1.16
 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -h
 e4:XXXXXXXX

This shows a basic test of the binary and some ID the binary creates.

If the binary works you can look at the USB dongle. When plugging in the USB dongle dmesg should show something like:

[134241.886972] usb 2-2: new full-speed USB device number 6 using xhci_hcd
[134242.036652] usb 2-2: New USB device found, idVendor=1547, idProduct=1000, bcdDevice= 0.01
[134242.036657] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[134242.036660] usb 2-2: Product: SG-Lock USB Key
[134242.036662] usb 2-2: Manufacturer: SG-Lock
[134242.038319] hid-generic 0003:1547:1000.0005: hiddev0,hidraw0: USB HID v1.00 Device [SG-Lock SG-Lock USB Key] on usb-0000:00:14.0-2/input0

With dongle installed, you can test for availability of the dongle:

 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -s
1
 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -t
XXXXXXX

(1 dongle found, ID of the SG lock dongle is some number).

Without dongle installed (or with dongle unreachable because of permissions):

 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -s
0
 $ .var/app/org.opencpn.OpenCPN/bin/oeserverd -t
0

(No dongle found, no ID from the dongle returned)

When a USB dongle is present but not found this usually points to either a permissions problem or a libusb problem

The libusb problem (udev)

This does only apply for versions before 5.6.0

Below the installed libusb for a Linux sytem with a working SG dongle

$ dpkg -l|grep libusb
ii  libusb-0.1-4:amd64                         2:0.1.12-32                           amd64        userspace USB programming library
ii  libusb-1.0-0:amd64                         2:1.0.23-2build1                      amd64        userspace USB programming library

Note that the 0.1-4 version is installed next to an higher version. This libusb version is necessary for the SG-lock library.

$ sudo apt install libusb-0.1-4

The permission problem (udev)

From version 5.6.0 there is interactive support for handling this issue

With OpenCPN 5.2 you can find the udev rule under /usr/lib/udev/rules/98-sglock-ocpn.rules which solves the permission problem.

The USB key should be readable and writeable for anyone. For OpenCPN 5.0 and older, use your favorite editor and create a file 98-sglock.rules with the content below

ATTRS{idVendor}=="1547", ATTRS{idProduct}=="1000", MODE="666", GROUP="20"

Move this file to /etc/udev/rules/

 $ sudo mv -vi 98-sglock.rules /etc/udev/rules/

Remove the USB dongle from your system and plug it in again. This should invoke the new udev rule.

The USB dongle should now be readable by any user:

 $ ls -l /dev/hidraw*
crw-rw-rw-   1 root dialout 245,   0 Apr 26 10:41 hidraw0

Now try the “oeserverd -s” sequence again and if this works start OpenCPN. Under Charts / oeSENC you should see a “System Name: sglXXXXXXXX (USB Key Dongle)” after pressing “Refresh Chart list” . (The hidraw device file will disappear after activating oeserverd, this is normal behaviour.)